<?php
class keu_setup_report_model extends MY_Model {
	var $model = 'keu_setup_report';
	
	function GetJSON()
	{
		$ls_sql	= "	SELECT	* 
					FROM	keu_setup_report 
					WHERE	(UPPER(kd_report) LIKE UPPER('%".post('keyword')."%')
							OR UPPER(nama_report) LIKE UPPER('%".post('keyword')."%'))
					ORDER BY ".(post('sort')=='' ? 'kd_report' : post('sort'))." ".(post('order')=='' ? 'asc' : post('order'));
					
		return json_encode( $this->paging($ls_sql) );
	}
		
	function Add($arr_data){
		$this->db->insert('keu_setup_report', $arr_data);
	}
	
	function Update($arr_data, $arr_trans){
		$this->db->update('keu_setup_report', $arr_data, $arr_trans);
	}
	
	function GetSingle($as_kd_report){
		$result = $this->db->get_where('keu_setup_report', array('kd_report' => $as_kd_report));
		if($result->num_rows() == 1){
			return $result->row_array();
		}else{
			return NULL;
		}
	}
	
	function GetSingleView($as_kd_report)
	{
		$result = $this->db->get_where('keu_setup_report', array('kd_report' => $as_kd_report));
		if($result->num_rows() == 1){
			return $result->row_array();
		}else{
			return NULL;
		}
	}

	function DeleteSingle($as_kd_report)
	{
		try {
			$this->db->delete('keu_setup_report', array('kd_report' => $as_kd_report));
			return '';
		} catch(Exception $e) {
			return $e->getMessage();
		}
	}
}
?>